package com.liusiqi.service;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 模拟高并发的kafka的生产
 */
@Component
public class KafkaSender {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    public void messageSender(String topic, String key, String message) {
        System.out.println("准备发送..."+topic+","+","+key);
        kafkaTemplate.send(topic, key, message);
        System.out.println("已发送");
    }
}
